package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.AnalysisIp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2018-11-26 15:04:55
 */
@Repository
public class AnalysisIpDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(AnalysisIpDao.class);

    public AnalysisIp insert(final AnalysisIp analysisIp) {
        insert("AnalysisIp.insert", analysisIp);
        return analysisIp;
    }

    public Boolean updateInfoById(final AnalysisIp analysisIp) {
        return update("AnalysisIp.updateInfoById", analysisIp) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("AnalysisIp.updateInfoByQuery", query) > 0;
    }

    public AnalysisIp selectById(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return queryForObject("AnalysisIp.selectById", query);
    }

    public List<AnalysisIp> selectByQuery(final Query query) {
        return queryForList("AnalysisIp.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("AnalysisIp.countByQuery", query);
    }

    public Boolean deleteById(final Integer id) {
        AnalysisIp analysisIp = new AnalysisIp();
        //analysisIp.setDeleteFlag(1);
        analysisIp.setId(id);

        return update("AnalysisIp.updateInfoById", analysisIp) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("AnalysisIp.deleteById", query) > 0;
    }
}